<%@page import="javabean.UserBean"%>
<%@page import="java.util.ArrayList"%>
<%
    ArrayList<UserBean> allUsers = (ArrayList) request.getAttribute("allUsers");
%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Insert title here</title>
        <link href="/./../../CSS/Site1.css" type="text/css" rel="stylesheet"/>
        <script language="javascript">
            function onCreateUser() {
                document.location.href = "../../../jsp/Account/CreateUser.jsp";
            }
            function onDeleteUser() {
                if (confirm("Selected users will be deleted? Are you sure?")) {
                    document.ListOfUserForm.action = "DeleteUserServlet";
                    document.ListOfUserForm.submit();
                    
                }
            }
        </script>
        
    </head>
    <body class="main">
        <div class="container">
            <div class="header">
                <div class="header_top_left"> 21/11/2012</div>
                <div class="header_top_right">maiphuong0403@gmail.com</div>
                <%--<div class="clear"></div>--%>
                <div class="header_main" > <img src="../../Images/12855184861024648803.jpg"/></div>
                    <%--<div class="clear"></div>--%>              
            </div>
                    <%@include file="../MasterPage.jsp" %>
            <h1>The list of users</h1>
            <div class="container_left">
                <form name="ListOfUserForm" action="" method="POST">
                    <table width="100%">
                        <tr>
                            <td colspan="10" align="right">
                                <a href="./GoAdminFunctionServlet">Main menu</a>
                                <a href="./LogoutServlet">Logout</a>
                            <td>
                        </tr>               
                        <tr bgcolor="gray" bordercolor="red">
                            <td><b>User name</b></td>
                            <td><b>Password</b></td>
                            <td><b>Sex</b></td>                    
                            <td><b>Full name</b></td>                    
                            <td><b>Day of birth</b></td>
                            <td><b>Email</b></td>
                            <td><b>Address</b></td>
                            <td><b>Role name</b></td>
                            <td></td>
                        </tr>
                        <% for (int i = 0; i < allUsers.size(); i++) {
                                UserBean currentUser = allUsers.get(i);
                        %>
                        <tr>
                            <td><a href="./ViewUserServlet?username="></a>
                                <%=currentUser.getUsername()%>
                            </td>
                            <td><%=currentUser.getPassword()%></td>
                            <td><%=currentUser.getFullname()%></td>
                            <td><%=currentUser.getSex()%></td>
                            <td><%=currentUser.getDOB()%></td>
                            <td><%=currentUser.getEmail()%></td>
                            <td><%=currentUser.getAddress()%></td>
                            <td><%=currentUser.getRole()%></td>
                            <td>
                                <input id="cboUser" type="checkbox" name="selectedUser" value="">
                            </td>
                        </tr>
                        <%
                            }%>

                        <tr><td colspan="10" align="right">
                                <input type="button" value="Back" onclick="history.back();">
                                <input type="button" value="Create" onclick="onCreateUser();">
                                <input type="button" value="Delete" onclick="onDeleteUser();">
                            <td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </body>
</html>
